Repository navigation
fix(cold-store-reaper): validate the Google token response before caching it (#6989) - #8702
Conversation
…hing it (#6989) BundleFlight.accessToken cached the token endpoint 200 body unvalidated, so one wrong-shape 200 poisoned every rehydration on the bundle DO until the bogus expiry. Now: a non-JSON body and any body that is not a plain object with a non-empty string token field throw HttpError(502) naming the token exchange and write nothing (the next call re-exchanges); expires_in is used only when a finite positive number, else the 3600s default; a cached entry whose token is not a non-empty string is treated as absent so poisoned entries self-heal. New test/token-response.test.mjs (wired into npm test): control cached once; empty/numeric/empty-string token, null, array, and non-JSON bodies all produce the shaped 502 with no cache write and a successful re-exchange; expires_in fallbacks; poisoned-cache self-heal. npm test: exit 0, 56 checks.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 962e92da5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ion; rebuild worker bundle (#6989)
Refs #6989
BundleFlight.accessToken()(the rehydrator Worker's Google token exchange) trusted the token endpoint's 200 body completely and wrote the unvalidated result to Durable Object storage as the cached token. One wrong-shape 200 —{}, a numeric token field, JSONnull, an error-page body — poisoned every later rehydration on that bundle DO until the bogus expiry passed, and the null/non-JSON cases escaped as rawTypeError/SyntaxErrorinstead of the module'sHttpErrorvocabulary. The Python sibling shaped this same boundary in #6846; the Worker door was not covered.Fix (
pkgs/cold-store-reaper/worker/src/index.js)HttpError(502, "google token exchange failed (…)"). A rejected response writes nothing to thegoogle_tokenentry, so the next call re-exchanges and can succeed.expires_inis used only when it is a finite positive number; otherwise the existing 3600s default applies — noNaN/negative expiry is ever cached.Tests
New
test/token-response.test.mjs, in the package's node test style (stub DO storage + stub token endpoint, as intest/range-ignored.test.mjs) and wired intonpm test: control response cached exactly once; empty-object / numeric / empty-string token fields, JSON null, JSON array, and non-JSON bodies each produce the shaped 502 with no cache write and a successful re-exchange afterwards;expires_inzero/negative/string/missing all fall back to 3600s; a poisoned cache entry re-exchanges.npm testinpkgs/cold-store-reaper/worker: exit 0, 56 checks passing.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.